import javax.swing.*;
import java.util.Arrays;

public class Code2 {


    public static void main(String[] args) {
        int[][] array = new int[2][];
        array[0] = new int[]{1,2,3,4,5};
        array[1] = new int[]{6,7};
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
        System.out.println(Arrays.deepToString(array));
    }



    public static void main8(String[] args) {
        int[][] array = new int[2][];
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }
    }



    public static void main7(String[] args) {
        int[][] array = {{1,2,3},{4,5,6}};
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }
    }




    public static void main6(String[] args) {
        int[][] array = {{1,2,3},{4,5,6}};
        System.out.println("打印的是地址");
        System.out.println(array[0]);
        System.out.println(array[1]);

        System.out.println("打印的是数组");
        System.out.println(Arrays.toString(array[0]));
        System.out.println(Arrays.toString(array[1]));
    }


    public static void main5(String[] args) {
        int[][] array = {{1,2,3},{4,5,6}};
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }



    //二维数组
    public static void main4(String[] args) {
        int[][] array1 = {{1,2,3},{4,5,6}};

        int[][] array2 = new int[][]{{1,2,3},{4,5,6}};

        int[][] array3 = new int[2][3];

        int[][] array4 = new int[2][];
    }



    public static void main3(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8,9};
        int[] copy = new int[array.length*2];
        System.arraycopy(array,2,copy,0,array.length-2);
        System.out.println(Arrays.toString(copy));
    }




    //数组拷贝
    public static int[] copy(int[] array){
        int[] CopyArray = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            CopyArray[i] = array[i];
        }
        return CopyArray;
    }

    public static void main2(String[] args) {
        int[] array1 = {1,2,3,4,5,6};
        //int[] array2 = copy(array1);
        //使用数组工具进行拷贝
        //int[] array2 = Arrays.copyOf(array1,array1.length);
        int[] array2 = Arrays.copyOf(array1,array1.length*2);

        //真正的扩容
        //array1 = Arrays.copyOf(array1,array1.length);
        //System.out.println(Arrays.toString(array1));


        System.out.println(Arrays.toString(array2));
    }


    public static void main1(String[] args) {
        int[] array1 = {1,2,3,4,5,6,7,8,9,10};
        int[] array2 = array1;
        System.out.println(Arrays.toString(array2));
    }
}
